package com.aidisp.model.admin;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="sys_group")
@GenericGenerator(name="groupIdGenerator",strategy="uuid")
public class Group {
	@Id
	@GeneratedValue(generator="groupIdGenerator")
	@Column(length=36)
	private String id;
	private String groupName;
	@ManyToOne
	@JoinColumn(name="parentGroup")
	private Group parentGroup;
	
	@ManyToMany(mappedBy="groups")
	@Cascade(value={CascadeType.SAVE_UPDATE})
	private Set<User> users;
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	public Group getParentGroup() {
		return parentGroup;
	}
	public void setParentGroup(Group parentGroup) {
		this.parentGroup = parentGroup;
	}
	public Set<User> getUsers() {
		return users;
	}
	public void setUsers(Set<User> users) {
		this.users = users;
	}
	
}
